package com.example.tsbs.binary;

public class SpreadLossFormat {
    /**数据块数量*/
    private Integer nBulk;
    /**名称*/
    private String name;

    /**数据维度数*/
    private Integer nDim;

    /**数据类型*/
    private String[] dType;

    /**各数据维度名称*/
    private String[] dimNames;

    /**各数据维度长度*/
    private Integer[] length;

    /**数据*/
    private Float data;

    public SpreadLossFormat(Integer nBulk, String name, Integer nDim, String[] dType, String[] dimNames, Integer[] length, Float data) {
        setNBalk(nBulk);
        setName(name);
        setNDim(nDim);
        setDType(dType);
        setDimNames(dimNames);
        setLength(length);
        setData(data);
    }

    // 合并字符串
    @Override
    public String toString() {
        return getNBalk() + getName() + getNDim() + getDType() + getDimNames() + getLength() + getData();
    }

    public static void main(String[] args) {
        String[] dType = {"double","double","double","double"};
        String[] disNames = {"hor","depth","range"};
        Integer[] lengths = {3,2,1};
        SpreadLossFormat bs = new SpreadLossFormat(1, "transLoss",3,dType,disNames, lengths, 110f);
        System.out.println(bs);
        System.out.println("**************************");
    }
    public void setNBalk(Integer nBulk) {this.nBulk = nBulk;}
    public String getNBalk() {return String.format("%4d", nBulk);}

    public void setName(String name) {this.name = name;}
    public String getName() {return String.format("%16s", name);}

    public void setNDim(Integer nDim) {this.nDim = nDim;}
    public String getNDim() {return String.format("%4d", nDim);}

    public void setDType(String[] dType) {this.dType = dType;}
    public String getDType() {
        String res = "";
        for (String i : dType) {
            res += String.format("%8s", i);
        }
        res += String.format("%8s", "string");
        return res ;
    }

    public void setDimNames(String[] dimNames) {this.dimNames = dimNames;}
    public String getDimNames() {String res = "";
        for (String i : dimNames) {
            res += String.format("%16s", i);
        }
        return res ;
    }

    public void setLength(Integer[] length) {this.length = length;}
    public String getLength() {
        String res = "";
        for (Integer i : length) {
            res += String.format("%4d", i);
        }
        return res;
    }

    public void setData(float data) {this.data = data;}
    public String getData() {
        return String.format("%f", data) ;
    }

}
